<?php
include_once dirname(__FILE__).'/SimpleRecordController.class.php';

if(!isset($template) || !is_array($template))
	$template = array();

if(!array_key_exists('index', $template) || !is_file($template['edit']))
	$template['index'] = DEFAULT_TEMPLATE_INDEX;

if(!array_key_exists('edit', $template) || !is_file($template['edit']))
	$template['edit'] = DEFAULT_TEMPLATE_EDIT;

if(!isset($formatter)) {
	include_once PATH_DEFAULT_FORMATTER;
	$formatter = DEFAULT_FORMATTER;
}

$record_controller = new SimpleRecordController(
	isset($title) ? $title : basename($_SERVER['PHP_SELF']),
	$template['index'], $template['edit'],
	isset($data) && is_dir($data) ? $data : DEFAULT_DB,
	$formatter
);

return array(
	'controller' => $record_controller,
	'route' => $record_controller->route()
);
?>